<?php

namespace app\api\controller;

use app\api\logic\Article;
use app\api\logic\ExamTime;
use app\api\logic\Swiper;
use app\common\model\AppConfig;
use app\common\model\Menu;
use think\facade\Config;
use think\response\Json;

class Index extends Base
{
    /**
     * index
     * @return Json
     */
    public function index(): Json
    {
        $appId = getAppId();
        $appIsAudit = appIsAudit();
        $config = app(AppConfig::class)->getByIdAndType($appId, 'wx_group');
        $configShare = app(AppConfig::class)->getByIdAndType($appId, 'share');
        $data = [
            'swiper' => app(Swiper::class)->getList(),
            'menuList' => app(Menu::class)->getIndexList(),
            'articleList' => app(Article::class)->getIndexList(),
            'examTime' => app(ExamTime::class)->getIndexExamData(),
            'appConfig' => [
                'appIsAudit' => $appIsAudit,
                'appVersion' => Config::get('mcp.appVersion'),
                'isIosVirtualPay' => isIosVirtualPay(),
                'showWxGroup' => !$appIsAudit && $config['showWxGroup'],
                'showWxGroupText' => $config['showWxGroupText'],
                'showIndexShareName' => $configShare['showIndexShareName'],
            ],
        ];
        return $this->response($data);
    }
}
